<template>
  <div>
    <el-card class="box-card" :body-style="{ padding: '10px 10px 2px 10px' }">
      <el-form :inline="true" :model="queryParam" class="demo-form-inline" size="medium">
        <el-form-item label="出库单号">
          <el-input v-model="queryParam.billNumber" placeholder="请输入出库单号" clearable></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onSubmit">查询</el-button>
          <el-button @click="reset">重置</el-button>
        </el-form-item>
      </el-form>
    </el-card>

    <el-card class="box-card" :body-style="{ padding: 10 }">
      <el-table :data="tableData" border style="width: 100%" height="58vh">
        <el-table-column v-for="item of tableProps" :key="item.props" :prop="item.prop" :label="item.title"
          :width="item.width">
          <template #default="scope">
            <div>{{ scope.row[item.prop] }}</div>
          </template>
        </el-table-column>
      </el-table>
    </el-card>
    <el-card class="box-card" :body-style="{ padding: 10 }">
      <pagination ref="pagination" :totalCount="totalCount" @pagination="pagination"></pagination>
    </el-card>
  </div>
</template>

<script>
import { outDelayedPage } from '@/api/rfid/outBill'
import moment from 'moment/moment'
export default {
  name: 'delayedReturn',
  data() {
    return {
      totalCount: 0, //总数
      //查询条件
      searchModel: {
        pageNo: 1,
        pageSize: 10,
      },
      queryParam: {},
      tableData: [],
      tableProps: [
        { title: '出库单号', prop: 'billNumber', width: '', checked: true },
        { title: '原定归还日期', prop: 'planBackDate', width: '', checked: true },
        { title: '延期归还日期', prop: 'delayedDate', width: '', checked: true },
        { title: '操作时间', prop: 'createTime', width: '', checked: true },
        { title: '操作人', prop: 'createByName', width: '', checked: true },
      ],
    }
  },
  mounted() {
    this.loadData()
  },

  methods: {
    onSubmit() {
      this.$refs.pagination.resetPagination()
    },
    reset() {
      this.queryParam = {}
      this.$refs.pagination.resetPagination()
    },
    loadData() {
      var param = Object.assign(this.queryParam, this.searchModel)
      outDelayedPage(param)
        .then((res) => {
          if (res.data.code === 200) {
            this.tableData = res.data.data.records
            this.totalCount = res.data.data.total
          } else {
            this.$message.error(res.data.message)
          }
        })
        .catch((err) => {
          this.$message.error(err)
        })
    },
    pagination(val) {
      this.searchModel.pageNo = val.page
      this.searchModel.pageSize = val.limit
      this.loadData()
    },
  },
}
</script>

<style scoped lang="less"></style>
